<style scoped>
.contain {
  background: #fff;
  border: 1px solid #e5ebec;
  padding: 20px;
  color: #000;
}
.title {
  font-size: 18px;
  padding: 10px 0;
  text-align: center;
}
.mutationInfo {
  background: #fff;
  border: 1px solid #e5ebec;
  padding: 0 10px;
}
.mutationInfo {
  display: flex;
}
.mutationInfo-left,
.mutationInfo-right {
  flex: 1;
  float: left;
}
.mutationInfo-left + .mutationInfo-right {
  margin-left: 40px;
}
.mutationInfo-left > div,
.mutationInfo-right > div {
  padding: 15px 0;
  border-bottom: 1px dashed #e5ebec;
}
.mutationInfo-left > div:last-of-type,
.mutationInfo-right > div:last-of-type {
  border-bottom: none;
}
.mutationInfo-left span,
.mutationInfo-right span {
  padding-left: 10px;
}
.ivu-layout {
  padding: 20px;
}
</style>

<template>
<Layout>
  <div style="background:#f5f7f9;">
    <div class="contain">
      <div class="title">{{mutationData.mutation}}</div>
      <div class="mutationInfo">
        <div class="mutationInfo-left">
          <div>AltCount :<span>{{mutationData.altCount}}</span></div>
          <div>
            <p>Cancer :<span>{{mutationData.cancer}}</span></p>
            <p>Freq :<span>{{mutationData.freq | formatDate}}</span></p>
          </div>
          <div>Chr :<span>{{mutationData.chr}}</span></div>
          <div>
            <!-- 从肿瘤变异位点跳转取start字段，检测变异位点取pos字段 -->
            <p>Start :<span>{{mutationData.start}}{{mutationData.pos}}</span></p>
            <p>End :<span>{{mutationData.end}}</span></p>
          </div>
          <div>Gene :<span>{{mutationData.gene}}</span></div>
        </div>
        <div class="mutationInfo-right">
          <div>Sample :<span>{{mutationData.sample}}</span></div>
          <div>
            <p>Ref :<span>{{mutationData.ref}}</span></p>
            <p>Ref_Count :<span>{{mutationData.refCount}}</span></p>
          </div>
          <div>
            <p>Study :<span>{{mutationData.study}}</span></p>
            <p>Study_Name :<span>{{mutationData.studyName}}</span></p>
          </div>
          <div>
            <p>TumorAllele1 :<span>{{mutationData.tumorAllele1}}</span></p>
            <p>TumorAllele2 :<span>{{mutationData.tumorAllele2}}</span></p>
          </div>
        </div>
      </div>
    </div>
  </div>
  </Layout>
</template>
<script>
export default {
  name:'mutation',
  data() {
    return {
      mutationData: {}
    };
  },
  // mounted() {
  //   this.mutationData = this.$store.state.mutationData;
  //   console.log(this.$store.state.mutationData);
  // },
  activated(){
    this.mutationData = this.$store.state.mutationData;
    console.log(this.$store.state.mutationData);
  },
  filters: {
    formatDate(data) {
      function toPercent(point) {
        var y = String(point).indexOf(".");
        var str;
        var count;
        if (String(point).indexOf("%") != -1) {
          return point;
        }
        if (y == -1) {
          str = Number(point * 100);
        } else {
          count = String(point).length - y;
          if (count >= 2) {
            str = Number(point * 100).toFixed(2);
          } else if (count == 1) {
            str = Number(point * 100).toFixed(1);
          }
        }

        str += "%";
        return str;
      }

      let freq;
      if (String(data).indexOf("%") != -1) {
        freq = data;
      } else {
        freq = toPercent(data);
      }
      return freq;
    }
  }
};
</script>

